package org.hadoop.hive.controller;

import org.apache.hadoop.fs.shell.Count;
import org.hadoop.hive.Dao.BaseDao;
import org.hadoop.hive.Utils.Data;
import org.hadoop.hive.Utils.HbaseUtils;
import org.hadoop.hive.Utils.Results;
import org.hadoop.hive.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 作者：Lapper
 * QQ656277239
 * vx:JavaAdmin123
 */
@RequestMapping("/Bigdata")
@RestController
public class bigController {
              @Autowired
              private BaseDao baseDao;
   @GetMapping("/Build")
    public Results<String> my() throws Exception {
String ok=baseDao.BuildData();
        return Results.success(ok);
}

@GetMapping("/create")
public  String create(){
       new HbaseUtils().createTable("bigdata","00001");
       return "ok";
}
@GetMapping("/AllData")
    public Results<Object> AllData() throws Exception {
    List<Alldata> alldata = baseDao.alldata();
    return Results.success(alldata);
}
@GetMapping("/QueryByAge")
public Results<Object> QueryByAge(){
    List<GroupByAgeSalary> groupByAgeSalaries = baseDao.AgeAndSalary();
    return Results.success(groupByAgeSalaries);

}
//全国岗位数
@GetMapping("/site")
    public  Results<Object> AllSite() throws Exception {
    Map<String, Integer> site = baseDao.Site();
    return Results.success(site);
}
//不同学历对应的岗位数
    @GetMapping("/majorandjob")
    public  Results<Object> majorandjob() throws Exception {
        Map<String, Integer> map = baseDao.majorAndJobs();
        return Results.success(map);
    }
@GetMapping("/Delete")
    public Results<String> Delete(@RequestParam String rowKey ) throws Exception {
       String ok=baseDao.remove(rowKey);
       return  Results.success(ok);
}
    @GetMapping("/select")
    public Results<Map<String,String>>Select(@RequestParam String rowKey ) throws Exception {
        Map<String,String> map=baseDao.Select(rowKey);
        return  Results.success(map);
    }
    @GetMapping("/Ebackgroundandjobs")
    public Results<Map<String,Integer>> Ebackground() throws Exception {
       Map<String,Integer> map=baseDao.EbackgroundandJobs();
       return  Results.success(map);
    }

    }
